rest api exception handling